<?php
/**
 * 用户投稿类
 * @author 肖小平
 *
 */
class UserContriAction extends BaseAction{
	/**
	 * 用户投稿列表
	 */
	public function user_contri_list(){
		$ac_id = $_GET['c_id'];
		$where = 'state=1';
		if ($ac_id){
			$where .= " and ac_id=$ac_id";
		}
		$where .=$this->my_where();
		import('ORG.Util.Page');// 导入分页类
		$count = M('Contri')->where($where)->count();
		$Page = new Page($count,10);//每页显示10条
		$show = $Page->show();
		$ac_list = M('ArticleClass')->where('p_id=3')->select();
		//获取文章分类，返回数组
		$ac_list_ = array();
		foreach ($ac_list as $k=>$v){
			$ac_list_[$v['id']] = $v;
		}
		$list=M('Contri')->where($where)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach($list as $k=>$v){
			$list[$k]['user'] = M('User')->where('id = '.$v['user_id'])->find();
			$list[$k]['pic'] = explode(',', $v['pic']); 
		}
		$this->assign('list',$list);
		$this->assign('page',$show);// 赋值分页输出
		$this->assign("ac_list",$ac_list_);
		$this->display();
	}
	/**
	 * 查看投稿
	 */
	public function user_contri_detail(){
		$obj = M('Contri')->where('id='.$_GET['id'])->find();
		$p_arr = explode(',', $obj['pic']);
		$this->assign('obj',$obj);
		$this->assign('p_arr',$p_arr);
		$this->display();
	}
	//搜索配置
	public function my_where(){
		$where = '';
		$search_word = $_GET['search_word'];
		if($search_word) {
			$where .= " and (title like '%$search_word%') ";
		}
		return $where;
	}
}

?>